package com.wodsy.phoenix.datadao.payc.dao.impl;

import com.wodsy.phoenix.datadao.base.BaseHibernateDao;
import com.wodsy.phoenix.datadao.payc.dao.PayWaterDao;
import com.wodsy.phoenix.dataobject.payc.model.PayWater;
import com.wodsy.phoenix.dataobject.payc.vo.PayStatusReq;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Repository;

/**
 * 名称：com.wodsy.phoenix.datadao.payc.dao.impl
 * 描述：<br>
 * 类型：JAVA<br>
 * 最近修改时间：13/03/2015 10:57<br>
 *
 * @author Jack Chan
 * @since 13/03/2015
 */
@Repository
public class PayWaterDaoImpl extends BaseHibernateDao<PayWater, Long> implements PayWaterDao {
    @Override
    @Autowired
    @Qualifier("payc")
    public void setSessionFactory(SessionFactory sessionFactory) {
        this.sessionFactory = sessionFactory;
    }

    @Override
    public Class<PayWater> getModelClass() {
        return PayWater.class;
    }

    public void updatePayWater(PayStatusReq statusReq) {
        String hql = "update PayWater pw set pw.status =:status, pw.tradeIdThird=:tradeIdThird, pw.payType=:payType where  pw.id=:payWaterId";
        Session session = super.getSession();
        Query query = session.createQuery(hql);
        query.setProperties(statusReq);
        query.executeUpdate();
    }
}
